package com.cisetech.web.bobocai.houtai;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.cisetech.mapper.bobocai.ActivityMapper;
import com.cisetech.service.ActivityService;
import com.cisetech.vo.Page;
import com.cisetech.vo.bobocai.LContent;

//活动或栏目控制器
@Controller
@RequestMapping(value="/activity")
public class ActivityController { 
	@Autowired
	ActivityService activityServiceImpl;
	@Autowired
	ActivityMapper activityMapper;
	//活动列表跳转页
	@RequestMapping(value="list",method=RequestMethod.GET)
	public ModelAndView index(HttpServletResponse response,HttpServletRequest request){
		ModelAndView v = new ModelAndView("houtai/activitylist");
		return v;
	}
	//活动ajax分页
	@ResponseBody
	@RequestMapping(value="/getListActivity",method=RequestMethod.POST)
	public Page<LContent> getListActivity(LContent content,HttpServletResponse response,HttpServletRequest request){
		Page<LContent> page = activityServiceImpl.findListActivity(content);
		return page;
	}
	//添加活动跳转页
	@RequestMapping(value="/addActivity",method=RequestMethod.GET)
	public ModelAndView addActivity(HttpServletResponse response,HttpServletRequest request){
		
		ModelAndView v = new ModelAndView("houtai/addactivity");
		return v;
	}
	//添加活动
	@ResponseBody
	@RequestMapping(value="/saveActivty",method=RequestMethod.POST)
	public String saveActivty(LContent lContent,HttpServletResponse response,HttpServletRequest request){
		lContent.setContent(request.getParameter("content"));
		lContent.setContents(request.getParameter("contents"));
		
		String state = activityServiceImpl.addActivity(lContent);
		return state;
	}
}
